<?php 


require "../common/Curl.php";

/**
 *	https://open.esign.cn/doc/detail?id=opendoc%2Fidentity_service%2Feaug1b&namespace=opendoc%2Fidentity_service
 * 	e签宝 认证服务API
 * 	信息对比----接口顺序排列封装
 *  使用请求签名鉴权方式
 *  下一个------------------ OCR接口+其他 ocr.php
 */


//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
 * [personTwoCon 个人2要素信息比对]
 * @param  [type] $idNo   [身份证号（大陆二代身份证）]
 * @param  [type] $name   [姓名]
 * @return [type]         [description]
 */
function personTwoCon($idNo,$name,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/base";
	$head_url = "/v2/identity/verify/individual/base";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
} 

/**
 * [personCompanyThreeCon 个人运营商3要素信息比对]
 * @param  [type] $idNo     [身份证号（大陆二代身份证）]
 * @param  [type] $name     [姓名]
 * @param  [type] $mobileNo [手机号（中国大陆3大运营商）]
 * @return [type]           [description]
 */
function personCompanyThreeCon($idNo,$name,$mobileNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/telecom3Factors";
	$head_url = "/v2/identity/verify/individual/telecom3Factors";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name,
		"mobileNo"=>$mobileNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
} 

/**
 * [personCompanyThreeCons 个人运营商3要素信息比对（详情版）]
 * @param  [type] $idNo     [身份证号（大陆二代身份证）]
 * @param  [type] $name     [姓名]
 * @param  [type] $mobileNo [手机号（中国大陆3大运营商）]
 * @return [type]           [description]
 */
function personCompanyThreeCons($idNo,$name,$mobileNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/telecom3Factors/detail";
	$head_url = "/v2/identity/verify/individual/telecom3Factors/detail";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name,
		"mobileNo"=>$mobileNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}

/**
 * [personBankThreeCon 个人银行卡3要素信息比对]
 * @param  [type] $idNo     [身份证号（大陆二代身份证）]
 * @param  [type] $name     [姓名]
 * @param  [type] $cardNo   [银行卡号]
 * @return [type]           [description]
 */
function personBankThreeCon($idNo,$name,$cardNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/bank3Factors";
	$head_url = "/v2/identity/verify/individual/bank3Factors";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name,
		"cardNo"=>$cardNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}

/**
 * [personBankThreeCons 个人银行卡3要素信息比对（详情版）]
 * @param  [type] $idNo     [身份证号（大陆二代身份证）]
 * @param  [type] $name     [姓名]
 * @param  [type] $cardNo   [银行卡号]
 * @return [type]           [description]
 */
function personBankThreeCons($idNo,$name,$cardNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/bank3Factors/detail";
	$head_url = "/v2/identity/verify/individual/bank3Factors/detail";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name,
		"cardNo"=>$cardNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}

/**
 * [personBankFourCon 个人银行卡4要素信息比对]
 * @param  [type] $idNo     [身份证号（大陆二代身份证）]
 * @param  [type] $name     [姓名]
 * @param  [type] $cardNo   [银行卡号（银联卡号）]
 * @param  [type] $mobileNo [银行预留手机号（非短信通知手机号）]
 * @return [type]           [description]
 */
function personBankFourCon($idNo,$name,$cardNo,$mobileNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/bank4Factors";
	$head_url = "/v2/identity/verify/individual/bank4Factors";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name,
		"cardNo"=>$cardNo,
		"mobileNo"=>$mobileNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
/**
 * [personBankFourCons 个人银行卡4要素信息比对（详情版）]
 * @param  [type] $idNo     [身份证号（大陆二代身份证）]
 * @param  [type] $name     [姓名]
 * @param  [type] $cardNo   [银行卡号（银联卡号）]
 * @param  [type] $mobileNo [银行预留手机号（非短信通知手机号）]
 * @return [type]           [description]
 */
function personBankFourCons($idNo,$name,$cardNo,$mobileNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/individual/bank4Factors/detail";
	$head_url = "/v2/identity/verify/individual/bank4Factors/detail";
    $data = [
		"idNo"=>$idNo,
		"name"=>$name,
		"cardNo"=>$cardNo,
		"mobileNo"=>$mobileNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}






/**
 * [organTwoCon 组织机构2要素信息比对]
 * @param  [type] $name    [组织机构名称]
 * @param  [type] $orgCode [组织机构证件号,支持15位工商注册号或统一社会信用代码]
 * @return [type]          [description]
 */
function organTwoCon($name,$orgCode,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/organization/enterprise/base";
	$head_url = "/v2/identity/verify/organization/enterprise/base";
    $data = [
		"name"=>$name,
		"orgCode"=>$orgCode
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
} 


/**
 * [organThreeCon 组织机构3要素信息比对]
 * @param  [type] $name         [组织机构名称]
 * @param  [type] $orgCode      [工商企业支持15位工商注册号或统一社会信用代码]
 * @param  [type] $legalRepName [组织法定代表人姓名]
 * @return [type]               [description]
 */
function organThreeCon($name,$orgCode,$legalRepName,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/organization/verify";
	$head_url = "/v2/identity/verify/organization/verify";
    $data = [
		"name"=>$name,
		"orgCode"=>$orgCode,
		"legalRepName"=>$legalRepName
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
} 


/**
 * [companyThreeCon 企业3要素信息比对]
 * @param  [type] $name         [企业名称]
 * @param  [type] $orgCode      [企业证件号,支持15位工商注册号或统一社会信用代码]
 * @param  [type] $legalRepName [企业法定代表人姓名]
 * @return [type]               [description]
 */
function companyThreeCon($name,$orgCode,$legalRepName,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/organization/enterprise/bureau3Factors";
	$head_url = "/v2/identity/verify/organization/enterprise/bureau3Factors";
    $data = [
		"name"=>$name,
		"orgCode"=>$orgCode,
		"legalRepName"=>$legalRepName
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
} 

/**
 * [lawyerThreeCon 律所3要素信息比对]
 * @param  [type] $name         [律所名称]
 * @param  [type] $codeUSC      [律所统一社会信用代码号]
 * @param  [type] $legalRepName [律所法定代表人姓名]
 * @return [type]               [description]
 */
function lawyerThreeCon($name,$codeUSC,$legalRepName,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/organization/lawFirm";
	$head_url = "/v2/identity/verify/organization/lawFirm";
    $data = [
		"name"=>$name,
		"codeUSC"=>$codeUSC,
		"legalRepName"=>$legalRepName
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}

/**
 * [noOrganThreeCon 非工商组织3要素信息比对]
 * @param  [type] $name         [组织机构名称]
 * @param  [type] $codeUSC      [社会组织统一社会信用代码证]
 * @param  [type] $legalRepName [社会组织法定代表人名称]
 * @return [type]               [description]
 */
function noOrganThreeCon($name,$codeUSC,$legalRepName,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/organization/social";
	$head_url = "/v2/identity/verify/organization/social";
    $data = [
		"name"=>$name,
		"codeUSC"=>$codeUSC,
		"legalRepName"=>$legalRepName
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}

/**
 * [organFourCon 企业4要素信息比对]
 * @param  [type] $name           [企业名称]
 * @param  [type] $orgCode        [企业统一社会信用代码或工商注册号]
 * @param  [type] $legalRepName   [企业法定代表人姓名]
 * @param  [type] $legalRepCertNo [企业法定代表人证件号]
 * @return [type]                 [description]
 */
function organFourCon($name,$orgCode,$legalRepName,$legalRepCertNo,$appId,$secret,$url){
	$urlss = $url."/v2/identity/verify/organization/enterprise/bureau4Factors";
	$head_url = "/v2/identity/verify/organization/enterprise/bureau4Factors";
    $data = [
		"name"=>$name,
		"orgCode"=>$orgCode,
		"legalRepName"=>$legalRepName,
		"legalRepCertNo"=>$legalRepCertNo
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}


